<?php

namespace App\Library\Traits\Orm;

use App\Models\ShopImagesModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

trait PetOrmTrait
{
    public function image(): BelongsTo
    {
        return $this->belongsTo(ShopImagesModel::class, 'pet_id', 'img_source_id')
            ->where('img_source_type', 8)->orderBy('img_sort')->orderBy('img_source_id');
    }

    public function images(): HasMany
    {
        return $this->hasMany(ShopImagesModel::class, 'img_source_id', 'pet_id')
            ->where('img_source_type', 8)->orderBy('img_source_id');
    }
}
